﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using MyLocalChurch.Constants;
using MyLocalChurch.Models.Enumerations;
using MyLocalChurch.Models.Resources;

namespace MyLocalChurch.Models.KidsChurch
{
    public class Guardian : ATracker
    {
        public int Id { get; set; }

        public virtual List<Barcode> Barcodes { get; private set; }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        [StringLength(200)]
        public string FirstName { get; set; }

        [StringLength(200)]
        public string MiddleName { get; set; }

        [StringLength(200)]
        public string LastName { get; set; }

        [StringLength(100)]
        public string NickName { get; set; }

        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        public int Gender { get; set; }

        [DataType(DataType.DateTime, ErrorMessageResourceName = "Invalid", ErrorMessageResourceType = typeof(ErrorMessages))]
        public DateTime? BirthDate { get; set; }

        [DataType(DataType.Text)]
        [Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ErrorMessages))]
        public string MobileNumber { get; set; }

        [RegularExpression(SystemConstants.EmailAddressRegex, ErrorMessageResourceName = "Invalid", ErrorMessageResourceType = typeof(ErrorMessages))]
        public string EmailAddress { get; set; }

        [StringLength(1000)]
        [DataType(DataType.MultilineText, ErrorMessageResourceName = "Invalid", ErrorMessageResourceType = typeof(ErrorMessages))]
        public string AdditionalInformation { get; set; }

        public virtual Photo Photo { get; set; }

        public virtual List<Kid> Kids { get; private set; }

        public Guardian()
        {
            Barcodes = new List<Barcode>();
            Kids = new List<Kid>();

            IsActive = true;
        }

        public override string ToString()
        {
            return string.Format("{0} {1} ({2})",
                                 FirstName ?? string.Empty,
                                 LastName ?? string.Empty,
                                 NickName ?? string.Empty);
        }
    }
}